/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-02-04
 * Time: 22:02
 */
public class test5 {
    /**
     * LeetCode 69  x的平方根
     */

    public int mySqrt(int x) {
        int left =0;
        int right =x;
        int ans=-1;
        while(left<=right){
            int mid = left+(right-left)/2;
            if((long)mid*mid<=x){
                ans = mid;
                left=mid+1;
            }else{
                right=mid-1;
            }
        }
        return ans;
    }
}
